package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.SysNbaTeam;
import com.ruoyi.system.mapper.SysNbaTeamMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysNbaPlayerMapper;
import com.ruoyi.system.domain.SysNbaPlayer;
import com.ruoyi.system.service.ISysNbaPlayerService;
import com.ruoyi.common.core.text.Convert;

/**
 * 球员信息Service业务层处理
 * 
 * @author yqg
 * @date 2023-11-02
 */
@Service
public class SysNbaPlayerServiceImpl implements ISysNbaPlayerService 
{
    @Autowired
    private SysNbaPlayerMapper sysNbaPlayerMapper;

    @Autowired
    private SysNbaTeamMapper sysNbaTeamMapper;

    /**
     * 查询球员信息
     * 
     * @param playerId 球员信息主键
     * @return 球员信息
     */
    @Override
    public SysNbaPlayer selectSysNbaPlayerByPlayerId(Integer playerId)
    {
        return sysNbaPlayerMapper.selectSysNbaPlayerByPlayerId(playerId);
    }

    /**
     * 查询球员信息列表
     * 
     * @param sysNbaPlayer 球员信息
     * @return 球员信息
     */
    @Override
    public List<SysNbaPlayer> selectSysNbaPlayerList(SysNbaPlayer sysNbaPlayer)
    {
        return sysNbaPlayerMapper.selectSysNbaPlayerList(sysNbaPlayer);
    }

    /**
     * 新增球员信息
     * 
     * @param sysNbaPlayer 球员信息
     * @return 结果
     */
    @Override
    public int insertSysNbaPlayer(SysNbaPlayer sysNbaPlayer)
    {
        Integer teamId =  sysNbaPlayer.getTeamId();
        SysNbaTeam team =  sysNbaTeamMapper.selectSysNbaTeamByTeamId(teamId);
        sysNbaPlayer.setTeamNameCn(team.getTeamNameCn());
        return sysNbaPlayerMapper.insertSysNbaPlayer(sysNbaPlayer);
    }

    /**
     * 修改球员信息
     * 
     * @param sysNbaPlayer 球员信息
     * @return 结果
     */
    @Override
    public int updateSysNbaPlayer(SysNbaPlayer sysNbaPlayer)
    {
        Integer teamId =  sysNbaPlayer.getTeamId();
        SysNbaTeam team =  sysNbaTeamMapper.selectSysNbaTeamByTeamId(teamId);
        sysNbaPlayer.setTeamNameCn(team.getTeamNameCn());
        return sysNbaPlayerMapper.updateSysNbaPlayer(sysNbaPlayer);
    }

    /**
     * 批量删除球员信息
     * 
     * @param playerIds 需要删除的球员信息主键
     * @return 结果
     */
    @Override
    public int deleteSysNbaPlayerByPlayerIds(String playerIds)
    {
        return sysNbaPlayerMapper.deleteSysNbaPlayerByPlayerIds(Convert.toStrArray(playerIds));
    }

    /**
     * 删除球员信息信息
     * 
     * @param playerId 球员信息主键
     * @return 结果
     */
    @Override
    public int deleteSysNbaPlayerByPlayerId(Integer playerId)
    {
        return sysNbaPlayerMapper.deleteSysNbaPlayerByPlayerId(playerId);
    }
}
